﻿<common:LayoutAwarePage
    x:Name="pageRoot"
    x:Class="MetroCash.PAccountBrowse"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    IsTabStop="false"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MetroCash"
    xmlns:common="using:MetroCash.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.Resources>

        <!-- TODO: Delete this line if the key AppName is declared in App.xaml -->
        <x:String x:Key="AppName">My Application</x:String>
    </Page.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Style="{StaticResource LayoutRootStyle}">
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <!-- Back button and page title -->
        <Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>
        <TextBlock x:Name="pageTitle" Grid.Column="1" Text="Browse your accounts" Style="{StaticResource PageHeaderTextStyle}"/>
        <TextBlock Visibility="Collapsed" x:Name="pageSubTitle" Grid.Row="1" Grid.Column="1" Text="Current balance: " Style="{StaticResource PageSubheaderTextStyle}" ></TextBlock>
        <!--<ScrollViewer x:Name="contentView" 
                      Grid.Row="2" Grid.Column="1" 
                      HorizontalScrollBarVisibility="Auto" 
                      VerticalScrollBarVisibility="Disabled"
                      HorizontalScrollMode="Enabled"
                      ZoomMode="Disabled"
                     >-->
        <GridView x:Name="lstAccount"
                              Grid.Row="2" Grid.Column="1" 
                              ItemsSource="{Binding}"
                              IsItemClickEnabled="True"
                              ItemClick="lstAccount_ItemClick_1"
                              SelectionMode="Multiple"
                              SelectionChanged="lstAccount_SelectionChanged_1"
                            ScrollViewer.IsHorizontalScrollChainingEnabled="False">
            <GridView.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Vertical" HorizontalAlignment="Center" Margin="20,0,20,0" Width="200" VerticalAlignment="Top">
                        <Image Width="200" Height="200" Stretch="UniformToFill"></Image>
                        <StackPanel VerticalAlignment="Top">
                            <TextBlock Text="{Binding Name}" Style="{StaticResource PageSubheaderTextStyle}" HorizontalAlignment="Center" TextWrapping="Wrap"></TextBlock>
                            <TextBlock Text="Balance" HorizontalAlignment="Center"></TextBlock>
                            <TextBlock Text="{Binding Balance}" HorizontalAlignment="Center" FontSize="{StaticResource MediumFontSize24}"></TextBlock>
                            <TextBlock Text="{Binding Description}" TextWrapping="Wrap" Margin="0,20,0,0"></TextBlock>
                        </StackPanel>

                    </StackPanel>
                </DataTemplate>
            </GridView.ItemTemplate>
        </GridView>
        <!--</ScrollViewer>-->
        <VisualStateManager.VisualStateGroups>

            <!-- Visual states reflect the application's view state -->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape"/>
                <VisualState x:Name="Filled"/>

                <!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <!-- The back button and title have different styles when snapped -->
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>

    </Grid>
    <Page.BottomAppBar>
        <AppBar x:Name="appbarBotom" 
                Padding="10, 0, 10, 0" 
                Opened="appbarBotom_Opened_1"
                Closed="appbarBotom_Closed_1"
                >
            <Grid>
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                    <Button x:Name="btnAppBarDelete" Style="{StaticResource DiscardAppBarButtonStyle}" AutomationProperties.Name="Delete accounts" Click="btnAppBarDelete_Click_1"></Button>
                    <Button x:Name="btnAppBarEdit" Style="{StaticResource EditAppBarButtonStyle}" AutomationProperties.Name="Edit account" Click="btnAppBarEdit_Click_1"></Button>
                    <Button x:Name="btnAppBarClear" Style="{StaticResource DeleteAppBarButtonStyle}" AutomationProperties.Name="Clear selection" Click="btnAppBarClear_Click_1"></Button>
                    <Button x:Name="btnAppBarAdd" Style="{StaticResource AddAppBarButtonStyle}" AutomationProperties.Name="New account" Click="btnCreateAccount_Click_1"></Button>
                </StackPanel>
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                    <Button x:Name="btnAppBarHelp" Style="{StaticResource HelpAppBarButtonStyle}"></Button>
                    <Button x:Name="btnAppBarHome" Style="{StaticResource HomeAppBarButtonStyle}"></Button>
                </StackPanel>
            </Grid>
        </AppBar>
    </Page.BottomAppBar>
</common:LayoutAwarePage>
